package cn.laowen.org.service.impl;

import cn.laowen.basic.util.PageList;
import cn.laowen.org.domain.Dictionary;
import cn.laowen.org.mapper.DictionaryEditMapper;
import cn.laowen.org.query.DictionaryEditQuery;
import cn.laowen.org.service.IDictionaryEditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DictionaryEditServiceImpl implements IDictionaryEditService {
    //1.一般业务实现可以通公共业务实现层来实现

    //2.特殊的业务实现需要自己重写

    @Autowired
    private DictionaryEditMapper dictionaryEditMapper;


    @Override
    public List<Dictionary> queryAll() {
        return dictionaryEditMapper.loadAll();
    }

    @Override
    public Dictionary queryById(Long id) {
        return dictionaryEditMapper.loadById(id);
    }


    @Override
    public void save(Dictionary dictionary) {
        dictionaryEditMapper.save(dictionary);
    }

    @Override
    public void update(Dictionary dictionary) {
        dictionaryEditMapper.update(dictionary);
    }


    @Override
    @Transactional
    public void removeById(Long id) {
        dictionaryEditMapper.deleteById(id);
    }

    @Override
    public PageList<Dictionary> queryPage(DictionaryEditQuery dictionaryEditQuery) {
        //查询总条数
        Long total = dictionaryEditMapper.queryCount(dictionaryEditQuery);
        //查询当页数据
        List<Dictionary> rows = dictionaryEditMapper.queryData(dictionaryEditQuery);

        return new PageList<Dictionary>(total,rows);
    }

    @Override
    @Transactional
    public void batchRemove(List<Long> ids) {
        dictionaryEditMapper.batchRemove(ids);
    }
}
